<template>
    <el-menu
        :style="{ width: !isCollapse ? '200px' : '64px' }"
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="aside-container"
        text-color="#fff"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
        :default-active="active"
    >
        <p class="logo-lg">{{ isCollapse ? 'DIDI' : 'DIDI陪诊' }}</p>
        <TreeMenu :index="1" :menuData="menuData" />
    </el-menu>
</template>
<script setup>
import TreeMenu from '../components/TreeMenu.vue'
import { useRouter } from 'vue-router'
import { reactive, computed } from 'vue'
import { useStore } from 'vuex'

const router = useRouter()
const store = useStore()
// const menuData = reactive(router.options.routes[0].children)
const menuData = computed(() => store.state.menu.routerList)
// console.log('router:', router)

// 使用computed（）自动追踪响应式更新
const isCollapse = computed(() => store.state.menu.isCollapse)
const active = computed(() => store.state.menu.menuActive)
const handleOpen = () => {}
const handleClose = () => {}
</script>

<style scoped lang="less">
.aside-container {
    height: 100%;
    .logo-lg {
        text-align: center;
        height: 50px;
        line-height: 50px;
        font-size: 20px;
        color: #fff;
    }
}
</style>
